package com.jtny.nytb.datafilling.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jtny.component.entity.PageParam;
import com.jtny.component.entity.WebResponse;
import com.jtny.nytb.datafilling.service.CertificateService;
import com.jtny.nytb.datafilling.vo.CCERCertificateVO;
import com.jtny.nytb.datafilling.vo.GreenCertificateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 证书填报管理Controller类
 *
 * @author 智慧能源中心-夏燕强
 * @version 1.0
 * @package com.jtny.nytb.energymonitor.datafilling.controller
 * @fileName CertificateController.java
 * @createTime 2023年09月22日 13:18
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@RestController
@Api(value = "证书填报管理", tags = "证书填报管理")
@RequestMapping("/datafilling/certificate")
public class CertificateController {

    @Autowired
    CertificateService certificateService;


    @ApiOperation("分页查询CCER证信息")
    @ApiImplicitParam(name = "param", value = "分页对象", required = true, paramType = "query", dataType = "PageParam")
    @ApiOperationSupport(order = 1)
    @PostMapping("/queryPageCCER")
    @ResponseBody
    public WebResponse<?> queryPageCCER(@RequestBody PageParam param) {
        return WebResponse.success(  certificateService.queryPageCCER(param));
    }

    @ApiOperation("保存CCER证信息")
    @ApiImplicitParam(name = "ccerCertificateVO", value = "CCER证信息VO对象", required = true, paramType = "query", dataType = "CCERCertificateVO")
    @ApiOperationSupport(order = 2)
    @PostMapping("/saveCCER")
    @ResponseBody
    public WebResponse<?> saveCCER(@RequestBody CCERCertificateVO ccerCertificateVO) {
        return WebResponse.success(certificateService.saveCCER(ccerCertificateVO));
    }

    @ApiOperation("修改CCER证信息")
    @ApiImplicitParam(name = "ccerCertificateVO", value = "CCER证信息VO对象", required = true, paramType = "query", dataType = "CCERCertificateVO")
    @ApiOperationSupport(order = 3)
    @PostMapping("/updateCCER")
    @ResponseBody
    public WebResponse<?> updateCCER(@RequestBody CCERCertificateVO ccerCertificateVO) {
        certificateService.updateCCER(ccerCertificateVO);
        return WebResponse.success();
    }

    @ApiOperation("删除CCER证")
    @ApiImplicitParam(name = "certificateIdList", value = "CCER证ID列表", required = true, paramType = "path")
    @ApiOperationSupport(order = 4)
    @PostMapping("/deleteCCER")
    @ResponseBody
    public WebResponse<?> deleteCCER(@RequestBody List<Long> certificateIdList) {
        certificateService.deleteCCER(certificateIdList);
        return WebResponse.success();
    }

    @ApiOperation("使用CCER证")
    @ApiImplicitParam(name = "certificateIdList", value = "CCER证ID列表", required = true, paramType = "path")
    @ApiOperationSupport(order = 5)
    @PostMapping("/enableCCER")
    @ResponseBody
    public WebResponse<?> enableCCER(@RequestBody List<Long> certificateIdList) {
        certificateService.disablePageTemplate(certificateIdList);
        return WebResponse.success();
    }

    @ApiOperation("分页查询绿证信息")
    @ApiOperationSupport(order = 6)
    @ApiImplicitParam(name = "param", value = "分页对象", required = true, paramType = "query", dataType = "PageParam")
    @PostMapping("/queryPageGreenCertificate")
    @ResponseBody
    public WebResponse<?> queryPageGreenCertificate(@RequestBody PageParam param) {
        return WebResponse.success(certificateService.queryPageGreenCertificate(param));
    }

    @ApiOperation("保存绿证信息")
    @ApiImplicitParam(name = "greenCertificateVO", value = "绿证信息VO对象", required = true, paramType = "query", dataType = "GreenCertificateVO")
    @ApiOperationSupport(order = 7)
    @PostMapping("/saveGreenCertificate")
    @ResponseBody
    public WebResponse<?> saveGreenCertificate(@RequestBody GreenCertificateVO greenCertificateVO) {
        return WebResponse.success( certificateService.saveGreenCertificate(greenCertificateVO));
    }

    @ApiOperation("修改绿证信息")
    @ApiImplicitParam(name = "greenCertificateVO", value = "绿证信息VO对象", required = true, paramType = "query", dataType = "GreenCertificateVO")
    @ApiOperationSupport(order = 8)
    @PostMapping("/updateGreenCertificate")
    @ResponseBody
    public WebResponse<?> updateGreenCertificate(@RequestBody GreenCertificateVO greenCertificateVO) {
        certificateService.updateGreenCertificate(greenCertificateVO);
        return WebResponse.success();
    }

    @ApiOperation("删除绿证")
    @ApiImplicitParam(name = "certificateIdList", value = "绿证ID列表", required = true, paramType = "path")
    @ApiOperationSupport(order = 9)
    @PostMapping("/deleteGreenCertificate")
    @ResponseBody
    public WebResponse<?> deleteGreenCertificate(@RequestBody List<Long> certificateIdList) {
        certificateService.deleteGreenCertificate(certificateIdList);
        return WebResponse.success();
    }

    @ApiOperation("使用绿证")
    @ApiImplicitParam(name = "certificateIdList", value = "绿证ID列表", required = true, paramType = "path")
    @ApiOperationSupport(order = 10)
    @PostMapping("/enableGreenCertificate")
    @ResponseBody
    public WebResponse<?> enableGreenCertificate(@RequestBody List<Long> certificateIdList) {
        certificateService.enableGreenCertificate(certificateIdList);
        return WebResponse.success();
    }

    @ApiOperation("获取绿证列表")
    @ApiOperationSupport(order = 11)
    @GetMapping("/detailGreenList")
    @ResponseBody
    public WebResponse<?> detailGreenList() {
        return WebResponse.success(certificateService.detailGreenList());
    }

    @ApiOperation("获取绿证购买量")
    @ApiOperationSupport(order = 12)
    @GetMapping("/countGreen")
    @ResponseBody
    public WebResponse<?> countGreen() {
        return WebResponse.success(certificateService.countGreen());
    }

    @ApiOperation("获取CCER列表")
    @ApiOperationSupport(order = 13)
    @GetMapping("/detailCCERList")
    @ResponseBody
    public WebResponse<?> detailCCERList() {
        return WebResponse.success(certificateService.detailCCERList());
    }

    @ApiOperation("获取CCER购买量")
    @ApiOperationSupport(order = 14)
    @GetMapping("/countCCER")
    @ResponseBody
    public WebResponse<?> countCCER() {
        return WebResponse.success(certificateService.countCCER());
    }
}
